package com.introduce;

/**
 * 重构前
 *
 * @author: cong zhi
 * @createDate: 2022/5/10 9:05
 * @updateUser: cong zhi
 * @updateDate: 2022/5/10 9:05
 * @updateRemark: 修改内容
 * @version: v1.0
 */
public class HelloWord {

    public static void main(String[] args) {

        System.out.println("Hello Java");

        //不正常的客户
        Site site = new Site();
        Customer cus1 = site.getCustomer();
        String strName;

        if (cus1 == null) {
            // 顾客名字
            strName = "occupant";
        } else {
            // 获取用户的名字
            strName = cus1.getName();
            System.out.println("Current Customer1: " + strName);
        }

        BillingPlan plan1;
        if (cus1 == null) {
            plan1 = BillingPlan.basic();
        } else {
            plan1 = cus1.getPlan();
        }
        System.out.println("Total Expand:" + plan1.getTotalExpand());
        /**
         * 正常客户
         */
        BillingPlan plan2 = new BillingPlan(100, 19);
        PaymentHistory history = new PaymentHistory();
        Customer cus = new Customer("xiaoming", plan2, history);
        site.setCustomer(cus);

        Customer cus2 = site.getCustomer();
        if (cus2 == null) {
            strName = "occupant";
        } else {
            // 获取用户的名字
            strName = cus2.getName();
        }
        if (cus2 == null) {
            plan1 = BillingPlan.basic();
        }else {
            plan1 = cus2.getPlan();
        }
        System.out.println("Total Expand:"+plan1.getTotalExpand());
    }
}
